from django.shortcuts import render_to_response
from django.template.context import RequestContext
from config import realConfig
from appengine_utilities.sessions import Session
from django.http import HttpResponseRedirect

def render_jum_response(request,filename,values=None):
    realConfig.currentHome='http://'+request.environ['HTTP_HOST']+'/'
    if values:
        values['config']=realConfig
    else:
        values={'config':realConfig}
    values['links']=realConfig.getLinks(request)
    return render_to_response(filename,values)
  
  
def verify_required(func):
    def _wrapper(request, *args, **kw):
      realConfig.currentHome='http://'+request.environ['HTTP_HOST']+'/'
      if realConfig.currentHome==realConfig.privateHome:
        session=Session()
        if not session.has_key('checked'):
          return HttpResponseRedirect('/main/verify/')
      return func(request, *args, **kw)
    return _wrapper
      
